<%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@include file="/wx/page/session.jsp"%>
<c:set var="userId" value="${param.userId}" />
<c:set var="deptId" value="${param.deptId}" />
<c:set var="deptCode" value="${param.deptCode}" />
<c:set var="deptParentId" value="${param.deptParentId}" />
<!DOCTYPE html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <title>修改密码</title>
    <link rel="stylesheet" href="${ctx}/wx/css/default.css"/>
    <script type="text/javascript" src="${ctx}/dwr/engine.js"></script>
    <script type="text/javascript" src="${ctx}/dwr/util.js"></script>
    <script type="text/javascript" src="${ctx}/wx/js/alert.js"></script>
    <script type="text/javascript" src="${ctx}/dwr/interface/UserService.js"></script>
</head>
<body>
<form id="accountForm" name="accountForm" method="post">
    <p class="contact-input">
        <input type="search" id="accountPassword1" name="accountPassword1" placeholder="新密码" maxlength="6" required />
    </p>
    <p class="contact-input">
        <input type="search" id="accountPassword2" name="accountPassword2" placeholder="重复密码" maxlength="6" required />
    </p>
    <p class="contact-submit">
        <input type="button" value="修改密码" onclick="updateAccountPassword()">
    </p>
</form>
</body>
</html>
<script type="text/javascript">
function updateAccountPassword(){
    if (validate($("accountForm"))) {
        var accountPassword1 = dwr.util.getValue("accountPassword1");
        var accountPassword2 = dwr.util.getValue("accountPassword2");
        if(accountPassword1 != accountPassword2){
            alert("两次输入的密码不一致，请重新输入");
            return false;
        }

        var account = new Account();
        account.accountId = "${accountId}";
        account.accountPassword = accountPassword1;

        UserService.updateAccountPassword(account, function () {
            alert("密码修改成功");
            location = "${ctx}/wx/page/home.jsp?userId=${userId}&deptId=${deptId}&deptCode=${deptCode}&deptParentId=${deptParentId}";
        });
    }
}
</script>
